function [ mpc ] = mpc_kolona_ref( sys, x, u, k )
load ref
load cons
Ts=sys.Ts;
mpc=InitMPC(sys,100*eye(2),1*eye(2),zeros(2));
nSample=100;

len=length(ref);
if((2*k+2*nSample)<=len)
    ref=ref(2*k-1:2*k+2*nSample-2);
else
    if(2*k<len)
        ref=ref(2*k-1:end);
    else
        ref=ref(1:2*nSample);
        ref(1:2*nSample)=0;
    end
    ref(2*nSample)=0;
endref(1:200)=0;
end

ref=ref';

mpc=MPCSampling(mpc,nSample,nSample,[]);
mpc=MPCbound(mpc,createBounds(sys,k,lb,[],-1),createBounds(sys,k,ub,[],1),[0;0],[]);
mpc=addMPCstate(mpc,x);
mpc=addMPCcontrol(mpc,u);
mpc=addMPCref(mpc,ref);
end

